{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These examples illustrate common operations on polyhedra using [Polyhedra.jl](https://github.com/JuliaPolyhedra/Polyhedra.jl):\n",
    "\n",
    "- [Intersection](#Intersection).\n",
    "- [Convex hull](#Convex-hull)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "using Polyhedra, CDDLib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intersection <a name=\"Intersection\"></a> \n",
    "\n",
    "Intersection of polyhedra is obtained with the [`intersect`](https://juliapolyhedra.github.io/Polyhedra.jl/latest/utilities.html#Base.intersect) function.\n",
    "\n",
    "Below we compute the intersection of two randomly generated polygons in V-representation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "P1 = polyhedron(SimpleVRepresentation(randn(15, 2)), CDDLibrary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "P2 = polyhedron(SimpleVRepresentation(randn(15, 2)), CDDLibrary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Pint = intersect(P1, P2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Notice that the H-representation of the resulting polyhedron has been computed, but not the V-representation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hrepiscomputed(Pint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "false"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vrepiscomputed(Pint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "npoints(Pint)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can plot the polygons and their intersection using the `plot` function. For further plotting options see the [Plots.jl](http://docs.juliaplots.org/latest/) documentation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: using Plots.P2 in module Main conflicts with an existing identifier.\n"
     ]
    }
   ],
   "source": [
    "using Plots"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip00\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip5000)\" points=\"\n",
       "0,400 600,400 600,0 0,0 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip01\">\n",
       "    <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip5000)\" points=\"\n",
       "29.2591,375.813 580.315,375.813 580.315,11.811 29.2591,11.811 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip02\">\n",
       "    <rect x=\"29\" y=\"11\" width=\"552\" height=\"365\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  77.6951,370.353 77.6951,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  191.639,370.353 191.639,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  305.582,370.353 305.582,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  419.526,370.353 419.526,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  533.47,370.353 533.47,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,359.043 572.049,359.043 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,264.505 572.049,264.505 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,169.968 572.049,169.968 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,75.4299 572.049,75.4299 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,375.813 580.315,375.813 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,375.813 29.2591,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  77.6951,375.813 77.6951,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  191.639,375.813 191.639,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  305.582,375.813 305.582,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  419.526,375.813 419.526,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  533.47,375.813 533.47,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,359.043 37.525,359.043 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,264.505 37.525,264.505 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,169.968 37.525,169.968 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5000)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,75.4299 37.525,75.4299 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 77.6951, 389.613)\" x=\"77.6951\" y=\"389.613\">-2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 191.639, 389.613)\" x=\"191.639\" y=\"389.613\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 305.582, 389.613)\" x=\"305.582\" y=\"389.613\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 419.526, 389.613)\" x=\"419.526\" y=\"389.613\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 533.47, 389.613)\" x=\"533.47\" y=\"389.613\">2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 363.543)\" x=\"23.2591\" y=\"363.543\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 269.005)\" x=\"23.2591\" y=\"269.005\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 174.468)\" x=\"23.2591\" y=\"174.468\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5000)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 79.9299)\" x=\"23.2591\" y=\"79.9299\">2</text>\n",
       "</g>\n",
       "<polygon clip-path=\"url(#clip5002)\" points=\"\n",
       "174.671,329.74 215.714,91.9539 366.849,94.7745 520.108,340.1 520.108,340.1 273.345,369.187 174.671,329.74 174.671,329.74 \n",
       "  \" fill=\"#0000ff\" fill-opacity=\"0.2\"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.2; fill:none\" points=\"\n",
       "  174.671,329.74 215.714,91.9539 366.849,94.7745 520.108,340.1 273.345,369.187 174.671,329.74 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5002)\" points=\"\n",
       "29.2591,279.408 67.6954,207.171 433.227,11.811 580.315,204.469 580.315,204.469 455.874,375.813 193.396,357.247 29.2591,279.408 29.2591,279.408 \n",
       "  \" fill=\"#ff0000\" fill-opacity=\"0.2\"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.2; fill:none\" points=\"\n",
       "  29.2591,279.408 67.6954,207.171 433.227,11.811 580.315,204.469 455.874,375.813 193.396,357.247 29.2591,279.408 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5002)\" points=\"\n",
       "174.671,329.74 208.848,131.731 280.994,93.1722 366.849,94.7745 502.399,311.753 502.399,311.753 478.226,345.037 306.667,365.259 254.244,361.551 174.671,329.74 \n",
       "  174.671,329.74 \n",
       "  \" fill=\"#ffff00\" fill-opacity=\"0.6\"/>\n",
       "<polyline clip-path=\"url(#clip5002)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.6; fill:none\" points=\"\n",
       "  174.671,329.74 208.848,131.731 280.994,93.1722 366.849,94.7745 502.399,311.753 478.226,345.037 306.667,365.259 254.244,361.551 174.671,329.74 \n",
       "  \n",
       "  \"/>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot(P1, alpha=0.2, color=\"blue\")\n",
    "plot!(P2, color=\"red\", alpha=0.2)\n",
    "plot!(Pint, color=\"yellow\", alpha=0.6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Convex hull <a name=\"Convex-hull\"></a> \n",
    "\n",
    "The binary convex hull operation between two polyhedra is obtained with the [`convexhull`](https://juliapolyhedra.github.io/Polyhedra.jl/latest/utilities.html#Polyhedra.convexhull) function.\n",
    "\n",
    "Below we compute the convex hull of the two randomly generated polygons in V-representation from the previous example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "Pch = convexhull(P1, P2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "npoints(Pch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip00\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip5600)\" points=\"\n",
       "0,400 600,400 600,0 0,0 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip01\">\n",
       "    <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polygon clip-path=\"url(#clip5600)\" points=\"\n",
       "29.2591,375.813 580.315,375.813 580.315,11.811 29.2591,11.811 \n",
       "  \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip02\">\n",
       "    <rect x=\"29\" y=\"11\" width=\"552\" height=\"365\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  77.6951,370.353 77.6951,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  191.639,370.353 191.639,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  305.582,370.353 305.582,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  419.526,370.353 419.526,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  533.47,370.353 533.47,17.2711 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,359.043 572.049,359.043 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,264.505 572.049,264.505 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,169.968 572.049,169.968 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:0.5; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  37.525,75.4299 572.049,75.4299 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,375.813 580.315,375.813 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,375.813 29.2591,11.811 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  77.6951,375.813 77.6951,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  191.639,375.813 191.639,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  305.582,375.813 305.582,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  419.526,375.813 419.526,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  533.47,375.813 533.47,370.353 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,359.043 37.525,359.043 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,264.505 37.525,264.505 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,169.968 37.525,169.968 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5600)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:1; fill:none\" points=\"\n",
       "  29.2591,75.4299 37.525,75.4299 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 77.6951, 389.613)\" x=\"77.6951\" y=\"389.613\">-2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 191.639, 389.613)\" x=\"191.639\" y=\"389.613\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 305.582, 389.613)\" x=\"305.582\" y=\"389.613\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 419.526, 389.613)\" x=\"419.526\" y=\"389.613\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 533.47, 389.613)\" x=\"533.47\" y=\"389.613\">2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 363.543)\" x=\"23.2591\" y=\"363.543\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 269.005)\" x=\"23.2591\" y=\"269.005\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 174.468)\" x=\"23.2591\" y=\"174.468\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5600)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 23.2591, 79.9299)\" x=\"23.2591\" y=\"79.9299\">2</text>\n",
       "</g>\n",
       "<polygon clip-path=\"url(#clip5602)\" points=\"\n",
       "174.671,329.74 215.714,91.9539 366.849,94.7745 520.108,340.1 520.108,340.1 273.345,369.187 174.671,329.74 174.671,329.74 \n",
       "  \" fill=\"#0000ff\" fill-opacity=\"0.2\"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.2; fill:none\" points=\"\n",
       "  174.671,329.74 215.714,91.9539 366.849,94.7745 520.108,340.1 273.345,369.187 174.671,329.74 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5602)\" points=\"\n",
       "29.2591,279.408 67.6954,207.171 433.227,11.811 580.315,204.469 580.315,204.469 455.874,375.813 193.396,357.247 29.2591,279.408 29.2591,279.408 \n",
       "  \" fill=\"#ff0000\" fill-opacity=\"0.2\"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.2; fill:none\" points=\"\n",
       "  29.2591,279.408 67.6954,207.171 433.227,11.811 580.315,204.469 455.874,375.813 193.396,357.247 29.2591,279.408 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5602)\" points=\"\n",
       "29.2591,279.408 67.6954,207.171 215.714,91.9539 433.227,11.811 580.315,204.469 580.315,204.469 520.108,340.1 455.874,375.813 273.345,369.187 193.396,357.247 \n",
       "  29.2591,279.408 29.2591,279.408 \n",
       "  \" fill=\"#008000\" fill-opacity=\"0.1\"/>\n",
       "<polyline clip-path=\"url(#clip5602)\" style=\"stroke:#000000; stroke-width:1; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  29.2591,279.408 67.6954,207.171 215.714,91.9539 433.227,11.811 580.315,204.469 520.108,340.1 455.874,375.813 273.345,369.187 193.396,357.247 \n",
       "  29.2591,279.408 \n",
       "  \"/>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot(P1, alpha=0.2, color=\"blue\")\n",
    "plot!(P2, color=\"red\", alpha=0.2)\n",
    "plot!(Pch, color=\"green\", alpha=0.1)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.6.0",
   "language": "julia",
   "name": "julia-0.6"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
